package com.javatest.springboot2ratelimit.advice;

import com.javatest.springboot2ratelimit.exception.RateLimitException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author lzy
 * @create 2020-07-21 下午3:37
 */
@ControllerAdvice
public class RateLimitExceptionHandleAdvice {

    @ResponseBody
    @ExceptionHandler(value = RateLimitException.class)
    public String rateLimitExceptionHandler(RuntimeException ex) {
        return "error: " + ex.getMessage();
    }
}
